/*************************************************************************
	> File Name: Algorithm.h
	> Author: 
	> Mail: 
	> Created Time: 2021年12月22日 星期三 15时25分40秒
 ************************************************************************/

#ifndef _WMARK_BUF_MANAGER_H
#define _WMARK_BUF_MANAGER_H
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <log/log.h>
#include <iostream>
#include "WmarkDev.h"
#include "wmark_dev.h"
#include "AlgorithmModule.h"

namespace camera
{
    namespace algorithm
    {
        typedef struct {
            uint8_t *buf;
            uint64_t bufMaxLen;
            wmark_buf_t property;

        }WmarkBuf;

        class WmarkBufManager
        {

        public:
            WmarkBufManager();
            ~WmarkBufManager();
            bool isInitWmarkBufs();
            WmarkBuf *getIndexWmarkBuf(int index);
            int hanlePngOverlay(algorithm_info_t &_hal);

        private:
            WmarkDev *mWmarkDev = NULL;

            std::mutex mWmarkBufsMutex;
            WmarkBuf *mWmarkBufsArray = NULL;
            uint32_t mWmarkBufsArrayNum = -1;

            int initWmarkBuf();
            int delWmarkBufs();

            bool isEnableWmark(string halCameraId, WmarkBuf &wmarBufInfo);
            int handlePng(algorithm_info_t &info, WmarkBuf &wmarBufInfo);
            int handleStr(algorithm_info_t &info, WmarkBuf &wmarBufInfo);
        };

    } // algorithm
} // camera
#endif